package com.wu.project.admin.api;

import com.wu.project.admin.annotations.Authorization;
import com.wu.project.admin.annotations.Log;
import com.wu.project.admin.component.JsonResult;
import com.wu.project.admin.entity.AdQueryVO;
import com.wu.project.admin.entity.AdvertisingDTO;
import com.wu.project.admin.service.AdvertisingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author xuan
 */
@RestController
@RequestMapping("/ad")
public class AdvertisingApi {

    @Autowired
    AdvertisingService advertisingService;

    @Log(name = "加载广告页面数据(轮播图)", isOpen = true)
    @PostMapping("/loadAd")
    @Authorization
    public JsonResult advertising(@RequestBody AdQueryVO adQueryVO) {
        return advertisingService.getAdvertising(adQueryVO);
    }

    @Authorization
    @Log(name = "更新广告是否启用状态", isOpen = true)
    @PostMapping("/updateState")
    public JsonResult updateAdvertisingState(@RequestBody AdvertisingDTO advertisingDTO) {
        return advertisingService.updateAdvertisingState(advertisingDTO);
    }
}
